#include <QApplication>
#include <QProcess>
#include <QDebug>

QProcess* lsProcess;
void globalFun();

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    QString program("/bin/ls");
    QStringList argumnets;
    argumnets << "-l" << "/dev";

    lsProcess = new QProcess;
    lsProcess->start(program, argumnets);
    // Qt5新的槽函数语法， 可以将信号连接到全局函数上
    QObject::connect(lsProcess, &QProcess::readyRead, &globalFun);
    return app.exec();
}

void globalFun()
{
    QString res = lsProcess->readAll();
    qDebug() << res;
}
